#include <vector>
#include <set>
#include <iostream>
#include <unordered_map>
#include <numeric>

using namespace std;

string longestCommonPrefix(vector<string>& strs) {
    int minLen = INT_MAX;
    for(int size = 0; size < strs.size(); size++){
        if(minLen > strs[size].size()){ minLen = strs[size].size(); }
    }
    string ret = "";
    for(int i = 0; i < minLen; i++){
        char s = strs[0][i];
        for(int j = 1; j < strs.size(); j++){
            if(s != strs[j][i]){
                return ret;
            }
        }
        ret += s;
    }
    return ret;
}

int main(){
    vector<string> strs = {"flower","flow","flight"};
    string ret = longestCommonPrefix(strs);
    for(char s : ret){
        cout << s;
    }
    cout << endl;
}